import './assets/css/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

import App from './App.vue'
import { setupRouter } from './router'
import { setupStore } from '@/stores'
// 异步函数，在创建之前执行
async function beforeCreate() {
  // await new Promise((resolve) => {
  //   setTimeout(() => {
  //     resolve(true)
  //   }, 2000)
  // })
}
// 异步函数，在挂载之后执行
async function mounted() {}

async function setupApp() {
  console.log('before create')
  await beforeCreate()
  console.log('after create')
  const app = createApp(App)

  // 配置 pinia-store
  setupStore(app)
  app.use(createPinia())
  app.use(ElementPlus)

  setupRouter(app)
  app.mount('#app')
  await mounted()
}

setupApp()
